package com.controller;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@Configuration
public class Controller {
		
	@Bean
	@LoadBalanced
	public RestTemplate getRestTemplate()
	{
		return new RestTemplate();
    }

	
	@RequestMapping(value = "/hello", method = RequestMethod.GET	)
	public String hello() {
		
		RestTemplate template = getRestTemplate();
		String retVal = template.getForEntity("http://sayHello/hello/Eureka", String.class).getBody();
		return "In Caller, " + retVal;
	}
}
